package com.kinghunt.misp.common.enums.userx;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * 证件类型枚举
 *
 * @author jiangtao
 * @date 2020-01-30 20:51.
 */
public enum CertificateTypeEnum {
    /**
     * 身份证
     */
    IDENTITY_CARD(1, "身份证"),
    /**
     * 护照
     */
    PASSPORT(2, "护照");

    @Getter
    private Integer type;
    @Getter
    private String desc;

    CertificateTypeEnum(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    private final static Map<Integer, CertificateTypeEnum> map = new HashMap<>(8);
    static {
        for (CertificateTypeEnum e : CertificateTypeEnum.values()) {
            map.put(e.getType(), e);
        }
    }

    public static CertificateTypeEnum getByType(Integer type) {
        if (Objects.isNull(type)) {
            return null;
        }
        return map.get(type);
    }
}
